﻿using Kylin.Wiki.Core.Enum;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace Kylin.Wiki.Model.Api
{
    /// <summary>
    /// 响应实体基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ApiResult<T>
    {
        /// <summary>
        /// 结果状态
        /// </summary>
        [Description("结果状态")]
        public bool Success { get; set; } = true;

        /// <summary>
        /// 结果消息
        /// </summary>
        [Description("结果消息")]
        public string Message { get; set; } = string.Empty;

        /// <summary>
        /// 错误状态码
        /// </summary>
        [Description("错误状态码")]
        public HttpStateCode Code { get; set; } = HttpStateCode.Success;

        /// <summary>
        /// 服务器时间
        /// </summary>
        [Description("服务器时间")]
        public DateTime Time
        {
            get { return DateTime.Now; }
        }

        /// <summary>
        /// 结果数据
        /// </summary>
        [Description("结果数据")]
        public T Data { get; set; }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public ApiResult()
        { 

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="success"></param>
        /// <param name="code"></param>
        /// <param name="message"></param>
        public ApiResult(bool success, HttpStateCode code = HttpStateCode.Success, string message = "")
        {
            this.Success = success;
            this.Code = code;
            this.Message = message;
        }


    }

    /// <summary>
    /// 分页响应实体基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ApiPageResult<T> : ApiResult<T>
    {
        /// <summary>
        /// 分页索引
        /// </summary>
        public int PageIndex { get; set; }
        /// <summary>
        /// 分页大小
        /// </summary>
        public int PageSize { get; set; }
        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public ApiPageResult()
        { 

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="success"></param>
        /// <param name="code"></param>
        /// <param name="message"></param>
        public ApiPageResult(bool success, HttpStateCode code = HttpStateCode.Success, string message = "")
        {
            this.Success = success;
            this.Code = code;
            this.Message = message;
        }
    }


}
